package com.sxw.hw_student.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sxw.hw_student.system.entity.Course;
import com.sxw.hw_student.system.mapper.CourseMapper;
import com.sxw.hw_student.system.service.ICourseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sxw
 * @since 2025-05-11
 */
@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements ICourseService {

    @Override
    public Page<Course> queryRolePage(Page<Course> page, String roleName) {
        //构造查询条件（创建一个查询条件的实例）
        LambdaQueryWrapper<Course> queryWrapper = new LambdaQueryWrapper<>();
        //如果roleName(查询调剂)为空，则不添加查询条件；如果不为空，则添加查询条件
        if (StringUtils.isNotBlank(roleName)){
            queryWrapper.like(Course::getCourseName,roleName);
            //querWrapper.like("user_name",userName);
        }
        //调用mybaties-plus的分页方法，传入查询条件和分页参数，返回分页查询后的结果
        return this.page(page,queryWrapper);
    }
}
